package personal.wang.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import personal.wang.enm.MessageTypeRegion;

/**
 * @className: BitUtil
 * @Description:
 * @Author: wangyifei
 * @Date: 2025/2/25 11:02
 */
public class BitUtil {
    private static Logger logger = LoggerFactory.getLogger(BitUtil.class);
    public static boolean testRegion(int target, int expected , MessageTypeRegion region){
        int move = region.getRegion()*8;
        int mask = 0b11111111 ;
        int result = ((mask << move) & target) >>> move;
        return expected == result;
    }

    public static int getRegion(int target , MessageTypeRegion region){
        int move = region.getRegion()*8;
        int mask = 0b11111111 ;
        return ((mask << move) & target) >>> move;
    }
}
